<div>
	<?
		$this->addSubview(
			'Curd_Helper_Title',
			array('data' => array(
				$options['@all']['module_title'] => ''
			))
		);
	?>

	<? if (!empty($message_data)): ?>
		<?
		$this->addSubview(
			'Curd_Helper_InfoMessage',
			array('options' => $options, 'message_data' => $message_data)
		);
		?>
		<?
		$this->addSubview(
			'Curd_Helper_ViewBox',
			array(
			'name_of_model' => $name_of_model,
			'id' => $message_data['id'],
			'action' => $message_data['message']
			)
		);
		?>
	<? endif; ?>

	<? if ($options['@all']['is_access_to_editing'] == 'true'): ?>
	<a href="/curd/add/<?=$name_of_model?>" style="float: left;" class="bt_green">
		<span class="bt_green_lft"></span>
		<strong><?=LANG_ADD_ELEMENT ?></strong>
		<span class="bt_green_r"></span>
	</a>
	<? endif;?>

	<? if (!empty($catalog)): ?>
		<table id="rounded-corner">
		<thead>
			<tr>
			<? $fields = array_keys($catalog[0]); ?>
			<? $isFirst = true ?>
			<? $iCountCols = -1 ?>
			<? foreach ($fields as $field): ?>
			<? $iCountCols ++ ?>
			<? if (@$options[$field]['display_in_catalog'] == 'true'): ?>
				<th class="<?if($isFirst){print'rounded-start';$isFirst=false;}else{print 'rounded';}?>">
					<? if (!empty($options[$field]['field_alias'])): ?>
						<? $ftitle = $options[$field]['field_alias'] ?>
					<? else: ?>
						<? $ftitle = $field ?>
					<? endif; ?>

					<? if ($options[$field]['sorting_in_catalog'] == 'true'): ?>
						<? if ($field != $sorting_by): ?>
							<a href="?sorting_by=<? print $field ?>"><? print $ftitle ?></a>
						<? else: ?>
							<? print $ftitle ?>
						<? endif; ?>
					<? else: ?>
						<? print $ftitle ?>
					<? endif; ?>
				</th>
			<? endif; ?>
			<? endforeach; ?>
			<? if ($is_show_list_of_actions): ?>
				<th style="width: 100px" class="rounded-end" ><?=LANG_ACTIONS?></th>
			<? endif; ?>
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="<? print $iCountCols ?>" class="rounded-foot-left"><em><?=LANG_SET_ELEMENT_FOR_ACTION?></em></td>
				<? if ($is_show_list_of_actions): ?>
					<td class="rounded-foot-right">&nbsp;</td>
				<? endif; ?>
			</tr>
		</tfoot>
			<?foreach ($catalog as $line): ?>
			<tr class='c-table-string'>
				<?foreach ($line as $key => $value): ?>
					<? if (@$options[$key]['display_in_catalog'] == 'true'):  ?>
					<td>
						<? print $value ?>
					</td>
					<? endif; ?>
				<?endforeach;?>

				<? if ($is_show_list_of_actions): ?>
					<td class="c-catalog-action">
						<? if (!empty($options['@all']['is_access_to_view'])): ?>
						<a class="ajax" href="/ajax/curd/view/<? print $name_of_model ?>?id=<? print $line['id'] ?>"><img src="/design/images/user_view.png" alt="<?=LANG_VIEW?>"></a>
						<? endif; ?>

						<? if (!empty($options['@all']['is_access_to_editing'])): ?>
						<a href="/curd/edit/<? print $name_of_model ?>?id=<? print $line['id'] ?>"><img src="/design/images/user_edit.png" alt="<?=LANG_EDIT?>"></a>
						<? endif; ?>

						<? if (!empty($options['@all']['is_access_to_remote'])): ?>
							<a href="/curd/delete/<? print $name_of_model ?>/?id=<? print $line['id'] ?>"><img src="/design/images/trash.png" alt="<?=LANG_DELETE?>"></a>
						<? endif; ?>
					</td>
				<?endif;?>
			</tr>
			<?endforeach; ?>
		</table>
	<? else: ?>
		<div><?=LANG_EMPTY_TABLE?></div>
	<? endif; ?>
</div>

<script type="text/javascript">
$(document).ready(function(){
	$(".ajax").fancybox({autoDimensions:false});

	var rgbTempColor = '#ECF8FD';
	$('#rounded-corner td:not(.c-catalog-action)').click(
		function(){
			if(rgbTempColor == '#ECF8FD') {
				$(this).children().css('background-color','#D4EFFA');
				rgbTempColor = '#D4EFFA';
			} else {
				$(this).children().css('background-color','#ECF8FD');
				rgbTempColor = '#ECF8FD';
			}
		}
	);
	$('.c-table-string').hover(
		function(){
			if($(this).children().css('background-color') != "rgb(212, 239, 250)") {
				rgbTempColor = '#ECF8FD';
			} else {
				rgbTempColor = '#D4EFFA';
			}
			$(this).children().css('background-color','#D2E7F0');
		},
		function (){
			$(this).children().css('background-color',rgbTempColor);
		}
	);
});
</script>

<?
$this->addSubview(
	'Curd_Helper_Paginate',
	array(
		'number_of_pages'	 => $number_of_pages,
		'current_page_number' => $current_page_number,
		'sorting_by'		  => $sorting_by
	)
);
?>